package com.kk.license.client.config;

import com.kk.license.client.interceptor.ChannelNumbersInterceptor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * @author wangkang
 * @version 1.0
 * @description 配置拦截器，用于验证通道数量是否超过
 * @create 2023-07-17 10:17
 */
@Component
@ConditionalOnClass(name={"com.kk.license.starter.config.LicenseAutoConfiguration"})
public class ChannelInterceptorConfig implements WebMvcConfigurer {
    @Resource
    private ChannelNumbersInterceptor channelNumbersInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        // 添加要拦截的url
        registry.addInterceptor(channelNumbersInterceptor)
                // 拦截的路径
                .addPathPatterns("/**/channel/**");
    }
}
